const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const env = require('./env')
const { NODE_ENV } = env

module.exports = {
  mode: '',
  entry: {
    app: './src/main.js'
  },
  output: {
    filename: '[name].[].js',
    path: path.resolve(__dirname, './dist'),
    publicPath: ''
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      }, {
        test: /\.js$/,
        loader: 'babel-loader',
      }, {
        test: /\.css$/,
        loader: 'css-loader'
      }, {
        test: /\.less$/,
        loader: ['css-loader', 'less-loader']
      }, {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10,
          name: 'static/images/[name].[hash:7].[ext]',
          esModule: false,
        }
      }
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        ...env,
        NODE_ENV: `"${env.NODE_ENV}"`,
      }
    }),
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({}),
  ]
}